<template name="商户征信查询记录查询">
  <base-view  :model="query" @submit="search">
    <template v-slot:params>
      <a-col :span="8">
        <a-form-model-item label="商户号">
          <a-input v-model="query.mchntNo" class="select" placeholder="请输入商户号" />
        </a-form-model-item>
      </a-col>
      <a-col :span="8">
        <a-form-model-item label="商户名称">
          <a-input v-model="query.mchntName" class="select"  placeholder="请输入商户名称" />
        </a-form-model-item>
      </a-col>
      <a-col :span="8">
        <a-form-model-item label="核查机构">
          <a-input v-model="query.checkInst" class="select" placeholder="请输入核查机构" />
        </a-form-model-item>
      </a-col>
      <a-col :span="8">
        <a-form-model-item label="核查操作员">
          <a-input v-model="query.checkPerson" class="select" placeholder="请输入核查操作员" />
        </a-form-model-item>
      </a-col>
      <a-col :span="24">
        <a-form-item>
          <a-button  @click="search" type="primary">搜索</a-button>
          <a-button style="margin-left: 8px" html-type="reset" @click="reset">重置</a-button>
        </a-form-item>
      </a-col>
    </template>
    <div class="section">
      <a-table
        ref="table"
        :columns="columns"
        :dataSource="dataSource"
        :rowKey="
          (record, index) => {
            return index;
          }
        "
        :loading="loading"
        :pagination="pagination"
        @change="search"
        @showSizeChange="search"
        :scroll="{ x: 2000 }"
      ></a-table>
    </div>
  </base-view>
</template>

<script>
import { mapState } from "vuex"
  export default {
    name: "CreditInvestigation",
    data() {
      return {
        query: {
          mchntNo: "",
          mchntName: "",
          checkInst: "",
          checkPerson: "",
        },
        beanInfo: {},
        operationType: "view",
        loading: false,
        pagination: {
          pageSizeOptions: ["10", "20", "30", "40", "100"],
          defaultCurrent: 1,
          defaultPageSize: 10,
          showQuickJumper: true,
          showSizeChanger: true,
          showTotal: (total, range) =>
            `显示 ${range[0]} ~ ${range[1]} 条记录，共 ${total} 条记录`,
        },
        columns: [
          {
            title: "成员机构",
            dataIndex: "instId",
            fixed: "left",
            width: 120,
          },
          {
            title: "商户号",
            dataIndex: "mchntNo",
            width: 120,
          },
          {
            title: "商户名称",
            dataIndex: "mchntName",
            width: 180,
          },
          {
            title: "核查机构",
            dataIndex: "checkInst",
            width: 120,
          },
          {
            title: "核查操作员",
            dataIndex: "checkPerson",
            width: 120,
          },
          {
            title: "系统流水号",
            dataIndex: "sysSeqNum",
            width: 120,
          },
          {
            title: "法人代表名称",
            dataIndex: "artifName",
            width: 120,
          },
          {
            title: "法人身份证号",
            dataIndex: "artifIdNo",
            width: 120,
          },
          {
            title: "核查时间",
            dataIndex: "checkTime",
            width: 120,
          },
          {
            title: "联网核查结果",
            dataIndex: "checkResult",
            width: 200,
          },
        ],
        dataSource: [],
      };
    },
       computed: {
    ...mapState({
      currentUser: state => state.account.user
    })
  },
    methods: {
       async reset() {
      // this.query = {instId:this.query.instId}
      this.query = {}
      this.pagination.pageNum = this.pagination.defaultCurrent;
      this.pagination.pageSize = this.pagination.defaultPageSize;
      if (!this.currentUser.admin) {
        this.query.instId = this.currentUser.instId;
        await this.search();
      }
    },
      async search(e) {
        e && e.preventDefault && e.preventDefault();
        try {
          const res = await this.$get("/admin/optLog/creditInvestigation/list", {
            instId: this.query.instId,
            mchntNo: this.query.mchntNo,
            mchntName: this.query.mchntName,
            checkInst: this.query.checkInst,
            checkPerson: this.query.checkPerson,
            pageNum: this.pagination.defaultCurrent,
            pageSize: this.pagination.defaultPageSize,
          });
          this.dataSource = res.data.rows;
          this.$set(this.pagination, "total", +res.data.total);
        } catch (e) {
          console.error(e);
        }
      },

      async submit() {
        const res = await this.$refs.modalForm.submit();
        if (res) {
          this.pagination.defaultCurrent = 1;
          await this.search();
        }
      },
    },
    mounted() {
      this.search();
    },
  };
</script>
<style lang="less" scoped>
  @import "../../../../../../static/less/Common";
</style>
